home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor2 / falseclr.s < prev    next >
Text File  |  1994-01-04  |  9KB  |  347 lines

  1. *    TITLE [ON]-[A]-[F] Trap Loop, Version 2.0
  2. ** begin BACKGRND.S *********************************************
  3. *****************************************************************
  4. **
  5. ** NAME: BACKGRND.S
  6. **
  7. ** CATEGORY: Memory
  8. **
  9. ** ENTRY: -
  10. **
  11. ** EXIT: -
  12. **                    
  13. ** ABSTRACT: Runs 48's keys in [ON]-[A]-[F] protected shell.
  14. **
  15. ** MODULE HISTORY:
  16. **
  17. ** Written            09/08/93    Rick Grevelle
  18. ** Completely Re-written        09/20/93        Jeoff Krontz
  19. **
  20. **
  21. ** Changes made:
  22. **      
  23. ** 1. May now use [ON] like normal
  24. ** 2. May now use [OFF] like normal
  25. ** 3. Keys aren't missed if typed quickly
  26. ** 4. If [A] or [F] is pressed before [ON], no memory is lost
  27. ** 5. May use key combinations now, like [ALPHA]-[LSHIFT]-[G].  You
  28. **    are no longer forced to do one key at a time.
  29. ** 6. Once memory is (falsely) cleared, the home directory now appears
  30. **    empty, so that determined people who hit [VAR] after the clear
  31. **    will think it worked.  (Uses a Null directory)
  32. ** 7. [ON]-[B] will restore the directory instantly.
  33. **
  34. **
  35. *****************************************************************
  36. *****************************************************************
  37.  
  38. ASSEMBLE
  39. sSX        EQU 0
  40. sFKEY        EQU 1
  41. Putkey        EQU #00D9F
  42. ClearDisplay    EQU #01BFF
  43. CONTRAST    EQU #00101
  44. NULLID        EQU #15777
  45. XeqInPlace    EQU #026BF
  46. ANNUNCIATORS    EQU #706C3
  47. DoingRecRam    EQU #71B29
  48. RecoverRam?    EQU #71B91
  49. G_XeqInPlace    EQU #7008B
  50. G_ANNUNCIATORS    EQU #80841
  51. G_DoingRecRam    EQU #81CBC
  52. G_RecoverRam?    EQU #81D24
  53.  
  54. RPL
  55. ::
  56.   BEGIN
  57.   AtUserStack
  58.   SysMenuCheck
  59.   SysDisplay
  60.  
  61. CODE
  62.     GOSBVL     =SAVPTR
  63.  
  64. **check to determine if GX or SX
  65.     D0=(5)  (=INHARDROM?)+14
  66.     C=DAT0    B            
  67.     ?CBIT=0    3            
  68.     GOYES    sx1
  69. gx1    ST=0    sSX
  70.     LC(5)    G_ANNUNCIATORS
  71.     GOTO    busyoff
  72. sx1     ST=1    sSX
  73.     LC(5)    ANNUNCIATORS
  74.  
  75. ** turn off the busy annunciator
  76. busyoff CD0EX
  77.     C=DAT0    B
  78.     CBIT=0    7
  79.     DAT0=C    B
  80.     D0=(5)    =ANNCTRL
  81.     C=DAT0    B        C[B]: [AON XTRA A6 A5 A4 A3 A2 A1]
  82.     CBIT=0    4        C[B]: [ *    *   *  0  *  *  *  *]
  83.     DAT0=C    B        turn off busy annunciator
  84.  
  85.     GOSUB    anykeys?    keys in buffer?  Yes -> quit
  86.     INTOFF                  interrupts off
  87.     ST=0    15        i
  88.     GOSUB    wait4nokeys    trap if someone keeps key pressed    
  89.  
  90. waitkey    SHUTDN                  Shut Down until key pressed  <----------
  91.     GOSBVL    =OnKeyDown?    is [ON] down?                |
  92.     GONC    skip            ** GOC On-A-F? out of range        |
  93.     GOTO      ON-A-F?        yes, check for [ON]-[A]-[F]        |
  94. skip    LC(3)     =allkeys    load entire keyboard            |
  95.     GOSUB     setkeys                            |
  96.     ?C=0      A        are no keys down?            |
  97.     GOYES     waitkey           no keys down, ------------------------->
  98.  
  99. ** see if the key down is [A] or [F]
  100. doublecheck
  101.     A=0       A
  102.     LA(2)     #10        load [A] mask
  103.     LC(3)     #2        activate OR1
  104.     ST=0      sFKEY        set looking at [A] key
  105.     GOSUB     setkeys
  106.     ?A=C      A        is [A] down?
  107.     GOYES     trapA_F        yes, trap that key
  108.     
  109.     ASR       B         load [F] mask (#01)
  110.     LC(3)     #100        activate OR8
  111.     ST=1      sFKEY        set looking at [F] key
  112.     GOSUB     setkeys
  113.     ?A=C      A        is [F] down?
  114.     GOYES     trapA_F        yes, trap that key
  115.     GOTO     exitwkeys    no,  exit & let key get passed to buffer
  116.  
  117. ** trap keys: wait until no keys down or [ON] is pressed
  118. trapA_F    GOSBVL =OnKeyDown?    <---------------------------------------
  119.     GOC ON-A-F?                            |
  120. *                                    |
  121.     LC(3)     =allkeys    load entire keyboard            |
  122.     GOSUB     setkeys                            |
  123.     ?C#0      A        is a key down?                |
  124.     GOYES     trapA_F        yes, ---------------------------------->
  125.     C=0     W
  126.     LC(1)     1        C[B]: keycode for [A]
  127.     ?ST=0      sFKEY        was it is [A] key pressed?
  128.     GOYES     Pushkey        yes, ---------------------------------->
  129.     LC(1)    6        no, C[B]: keycode for [F]        |
  130. Pushkey GOSBVL     Putkey          <---------------------------------------
  131.      GOTO     exitwkeys
  132.  
  133. ON-A-F?    LA(5)     #8010        load [ON]-[B] & [ON]-[A] mask  <-----------
  134.      LC(3)     #100           activate OR8 (looking for [ON]-[B] first)  |
  135.      GOSUB     setkeys                               |
  136.      ?A=C     A        is [ON]-[B] down?               |
  137.      GOYES     ON-B                               |
  138. *                                       |
  139.      ?C#0     A            are keys down?                   |
  140.      GOYES     checkON-A-F    yes, ---------------------------------->   |
  141.      GOTO     exit_after_on    leave with [ON] treated as [ATTN]    |  |
  142. *                                    |  |
  143. checkON-A-F                    *<---------------------------------------   |
  144.      LC(3)     #2             activate OR1 (looking for [ON]-[A] now)    |
  145.      GOSUB    setkeys                               |
  146.      ?A#C     A        is [ON]-[A] down?               |
  147.      GOYES     ON-A-F?        no, -------------------------------------->
  148. *                                |
  149.      ASR       B           load [ON]-[F] mask (#8001)    |
  150.      LC(3)     #100        activate OR8            |
  151.      GOSUB     setkeys                        |
  152.      ?A=C     A        is [ON]-[F] down?        |
  153.      GOYES     FALSECLR    yes, ---------------------------------->
  154.      GOTO     ON-A-F?        --------------------------------/    |
  155. *                                    |
  156. *                                    |
  157. ON-B     ST=1       15        turn interrupts back on            |
  158.      LA(5)      =FALSE                            |
  159.      GOSBVL     =GETPTR                            |
  160.      PC=(A)            return to sys-rpl shell            |
  161. *                                    |
  162. ** the FalseClear routine was written by Rick Grevelle            |
  163. ** with modifications by myself to change some things so        |
  164. ** that they would more closely emulate the a "true" clear         |
  165. FALSECLR                       *<---------------------------------------
  166.      GOSUB     wait4nokeys    wait until they let go of the keys
  167.      D0=(5)     CONTRAST    change contrast to HP default
  168.      C=0        A
  169.     ?ST=1    sSX
  170.     GOYES    sxcon
  171. gxcon    LC(2)    #E
  172.     GOTO    docon
  173. sxcon     LC(2)      #B
  174. docon     DAT0=C     B
  175.      ?ST=1      sSX
  176.      GOYES      sx2        jump to GX or SX routine
  177.  
  178. ** display "Try to Recover Memory?" screen
  179. gx2     LC(5)      G_RecoverRam?
  180.      GOSBVL     G_XeqInPlace
  181.      GOTO     wait4yes/no
  182. sx2
  183.      LC(5)      RecoverRam?
  184.      GOSBVL     XeqInPlace
  185.  
  186. wait4yes/no                    *<---------------------------------------
  187.      LC(3)     =allkeys    load entire keyboard            |
  188.      OUT=C                                |
  189.      SHUTDN            Shut Down until key pressed        |
  190.      A=0   A                                |
  191.      C=0   A                                |
  192.      LA(2) #10        load [A] mask                |
  193.      LC(1) #2        activate OR1                |
  194.      GOSUB setkeys                            |
  195.      ?C=A  A            is [A] down?                |
  196.      GOYES yesdown                            |
  197.      ASR   B            load [F] mask (#01)            |
  198.      LC(3) #100        activate OR8                |
  199.      GOSUB setkeys                            |
  200.      ?C=A  A            is [F] down?                |
  201.      GOYES nodown                            |
  202.      LC(2) #C6                            |
  203.      GOSBVL =RCKBp        do bad key beep                |
  204.      GOSUB wait4nokeys                        |
  205.      GOTO wait4yes/no    --------------------------------------->
  206.  
  207. yesdown ?ST=1 sSX
  208.      GOYES sx3
  209.  
  210. ** Display "Trying to Recover Ram" message
  211. gx3    LC(5)  G_DoingRecRam
  212.      GOSBVL G_XeqInPlace
  213.      GOTO    skip2
  214. sx3     LC(5)  DoingRecRam
  215.      GOSBVL XeqInPlace
  216.  
  217. skip2     LC(5) 8192*3        three second delay
  218.      GOSUB timing
  219.      LA(5) =TRUEFALSE
  220.      GOTO LEAVE
  221.  
  222. nodown     GOSBVL ClearDisplay    clear display like "true" clear
  223.      LC(5)  8192        one second delay
  224.      GOSUB timing
  225.      LA(5) =FalseFalse
  226.      GOTO LEAVE
  227.  
  228. exitwkeys
  229.      LC(3) =allkeys        load entire keyboard
  230.      OUT=C            enable keys to enter buffer upon exit
  231.      LA(5)  =TrueTrue
  232.      GOTO LEAVE        exit
  233.  
  234. exit_after_on
  235.      LA(5)  =FALSETRUE
  236. LEAVE     ST=1   15        turn interrupts back on
  237.      GOSBVL =GPPushA
  238.      LA(5)  =TRUE
  239.      PC=(A)            return to sys-rpl shell
  240.  
  241. wait4nokeys                    *<---------------------------------------
  242.      LC(5) =allkeys        load entire keyboard            |
  243.      GOSUB setkeys                            |
  244.      ?C#0 A            any keys pressed?            |
  245.      GOYES wait4nokeys    yes, ---------------------------------->
  246.      RTN
  247.  
  248. ** check if keys if buffer. if so, exit
  249. anykeys?
  250.      GOSBVL =KeyInBuff?    check if key in buffer (carry will get set)
  251.      GOC    exitwkeys    yes, then exit
  252.      C=0    A
  253.      RTN
  254.  
  255. setkeys    OUT=C
  256.      GOSBVL =CINRTN
  257.      RTN
  258.  
  259. ** timing routine that yields equal times on GX & SX
  260. timing     R1=C
  261.      GOSBVL =GetTimChk
  262.      R2=C
  263. delay     GOSBVL =GetTimChk
  264.      A=R2
  265.      P=     12
  266.      C=C-A  WP
  267.      A=R1
  268.      ?A>=C  WP
  269.      GOYES  delay
  270.      P=     0
  271.      RTN
  272. ENDCODE
  273.  
  274. * when the above code object exits, there will either be a 'FALSE' or
  275. * a 'TRUE along with two other flags'.
  276.   ITE                    
  277.   ::                    (routine for normal keys)
  278.     EVAL ITE                 (this splits the FLAGFLAG object)
  279.     ::
  280.       ITE                 (any key but [ON])
  281.       ::
  282.         GetKeyOb
  283.         ERRSET    DoKeyOb
  284.         ERRTRAP    SysErrorTrap
  285.       ;
  286.       ::                ([ON] routine)
  287. * the following code objects returns a flag with the state of the
  288. * right-shift annunciator, to determine between [ATTN] and [OFF]
  289. CODE                    
  290.     AD0EX
  291.     D0=(5)    (=INHARDROM?)+14
  292.     C=DAT0    B
  293.     ?CBIT=0    3
  294.     GOYES    sx4
  295. gx4    D0=(5)    G_ANNUNCIATORS
  296.     GOTO    skip4
  297. sx4    D0=(5)    ANNUNCIATORS
  298. skip4    C=DAT0    B
  299.     AD0EX
  300.     ?CBIT=1    5
  301.     GOYES    annexit
  302. annexit    GOVLNG    =PushT/FLoop
  303. ENDCODE
  304.  
  305.           case    ::  SetKeysNS  TurnOffKey ;    (routine to shut [OFF])
  306.           InitEd&Modes                 (routine to do [ATTN])
  307.           FLUSHKEYS
  308.         ;
  309.       ;
  310.       ::                
  311.         FLUSHKEYS            (take care of false-clear)
  312.         %3  InitMenu%            (set MTH menu)
  313.         FIFTYSIX  ClrSysFlag        (enable beeps)
  314.         HOMEDIR                (set home directory)
  315.         ' SetHiddenRes            (hide the home directory)
  316.         Ob>Seco
  317.         NULLID
  318.         DUPDUP
  319.         @ DROP
  320.         TYPERRP?
  321.         ITE_DROP
  322.         PURGE
  323.         CREATE
  324.         InitEd&Modes            (do an ATTN)
  325.         FLUSHKEYS        
  326.         NOT IT                (do MEMORY CLEAR?)
  327.         ::
  328.           FIVE  JstGETTHEMSG  DISPROW1    (display MEMORY CLEAR message)
  329.           BINT_91d  #578  setbeep    (do clear BEEP)
  330.           SetDA1Temp
  331.         ;
  332.         DEPTH NDROP            (clear stack)
  333.       ;
  334.     ;
  335.     ::                    ([ON]-[B] routine)
  336.       NULLID                (restore home directory)
  337.       SAFE@_HERE 
  338.       NOT?SEMI
  339.       TYPERRP?
  340.       ?SEMI
  341.       NULLID
  342.       PURGE 
  343.     ;
  344.   AGAIN
  345. ;
  346.  
  347.